package com.tjdr.his.domain.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tjdr.his.domain.entity.DrugInfo;
import com.tjdr.his.domain.entity.Employee;
import com.tjdr.his.domain.entity.GiveBackRecords;
import com.tjdr.his.domain.entity.Register;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IGiveBackRecordsMapper extends BaseMapper<GiveBackRecords> {

    @Select("select * from give_back_records ")
    @Results({
            @Result(column ="register_id" ,property ="registerId" ),
            @Result(column ="id" ,property ="id" ),
            @Result(column ="drug_id" ,property ="drugId" ),
            @Result(column ="date" ,property ="date" ),
            @Result(column ="employee_id" ,property ="employeeId" ),
            @Result(column ="cost" ,property ="cost" ),
            @Result(column ="number" ,property ="number" ),
            @Result(column ="operator_state" ,property ="operatorState" ),
            @Result(
                    column = "drug_id",//将来根据drug_id来查询
                    property = "drugInfo",//查询出来的数据封装到哪个属性里
                    javaType = DrugInfo.class,
                    one = @One(select = "com.tjdr.his.domain.mapper.IDrugInfoMapper.selectById")//根据drug_id查询出药品的信息这样的方法
            ),
            @Result(
                    column = "employee_id",
                    property = "employee",
                    javaType = Employee.class,
                    one = @One(select = "com.tjdr.his.domain.mapper.IEmployeeMapper.selectById")//根据drug_id查询出药品的信息这样的方法
            ),
            @Result(
                    column = "register_id",
                    property = "register",
                    javaType = Register.class,
                    one = @One(select = "com.tjdr.his.domain.mapper.IRegisterMapper.selectById")//根据drug_id查询出药品的信息这样的方法
            )
    })
    List<GiveBackRecords> selectRecords();
}
